/**
  * Created by wyc on 6/9/2017.
  */
package ninenineqs

object p01 {
  def last_v1[T](input:List[T]):T = {
    input.last
  }
  def last_v2[T](input:List[T]):T = {
    input.reverse.head
  }
  def last_v3[T](input:List[T]):T = {
    input match {
      case h :: Nil => h
      case _ :: tail => last_v3(tail)
      case Nil => throw new NoSuchElementException
    }
  }
}
